<template>
    <el-row>
        <el-col :span="2" :offset="1">
            <!-- 将其设计为一个计算属性 -->
            <el-checkbox v-model="isCheck"></el-checkbox></el-col>
        <el-col :span="6" :offset="2">{{ item.title }}</el-col>
        <el-col :span="3" :offset="5">
            <el-button type="danger" @click="delItem">删除</el-button>
        </el-col>
    </el-row>
</template>

<script lang="ts">
import { computed, defineComponent } from "vue";

export default defineComponent({
    props: ["item", "del", "index", "changeFlag"],
    setup(props) {
        const delItem = () => {
            props.del(props.index);
        };

        const isCheck = computed({
            get() {
                return props.item.flag;
            },
            set(value) {
                // console.log(value);
                props.changeFlag(props.item, value);
            },
        });
        return {
            delItem,
            isCheck,
        };
    },
});
</script>

<style scoped>

</style>